package com.financial.service.yspay.service.impl;

import com.financial.service.yspay.constants.YsServiceEnumConstants;
import com.financial.service.yspay.service.FinancialYsPayService;
import com.financial.service.yspay.service.pay.FinancialYsAliPayService;
import com.financial.service.yspay.service.pay.FinancialYsWeChatPayService;
import com.financial.service.yspay.utils.JsonUtils;
import com.financial.service.yspay.utils.apiresult.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //TODO
 * @Date 2019/11/13 10:33
 */
@Service
public class FinancialYsPayServiceImpl implements FinancialYsPayService {
    @Autowired
    private FinancialYsWeChatPayService financialYsWeChatPayService;

    @Autowired
    private FinancialYsAliPayService financialYsAliPayService;

    @Override
    public ApiResult ysPay(String requestParam) {
        /*银盛支付业务处理---判断是哪种支付渠道*/
        Map<String, Object> condMap = JsonUtils.jsonToMap(requestParam);
        String payType = (String) condMap.get("pay_type");
        ApiResult apiResult = null;
        if (payType.equalsIgnoreCase(YsServiceEnumConstants.ENUM_PAYTYPE_WECHAT)) {
            /*微信支付*/
            apiResult = financialYsWeChatPayService.ysWeChatPay(requestParam);
        } else if (payType.equalsIgnoreCase(YsServiceEnumConstants.ENUM_PAYTYPE_ALI)) {
            /*支付宝支付*/
            apiResult = financialYsAliPayService.ysAliPay(requestParam);
        }
        return apiResult;
    }
}
